package api;

import conf.App;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
import util.HttpClientUtil;
import util.ResponseData;

import java.io.IOException;
import java.net.URISyntaxException;
import java.security.PublicKey;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class WebVerifyCodeApi {
        private static final String verify_url= App.User_URL+"/common/public/verifycode1/%s";
        private static final String phone_url=App.User_URL+"/member/public/sendSms";
        private static final Logger logger= LoggerFactory.getLogger(WebVerifyCodeApi.class);
        private static final String reg_url=App.User_URL+"/member/public/reg";
        public ResponseData get_verify(String Id) throws IOException, URISyntaxException {
            logger.info("Id={}",Id);
            String format = String.format(verify_url, Id);
            return HttpClientUtil.get(format);
        }
        public ResponseData get_phone(String phone,String img_code,String type) throws IOException, URISyntaxException {
            Map<String,String> data=new HashMap<>();
            data.put("phone",phone);
            data.put("imgVerifyCode",img_code);
            data.put("type",type);
//            HttpClientUtil.build_header("Content-Type","application/x-www-form-urlencoded");
            return HttpClientUtil.post_form(phone_url, data);
        }
        public ResponseData get_reg(String phone,String password,String verifycode,String phone_code,String dy_server ) throws IOException, URISyntaxException {
            Map<String,String> data=new HashMap<>();
            data.put("phone",phone);
            data.put("password",password);
            data.put("verifycode",verifycode);
            data.put("phone_code",phone_code);
            data.put("dy_server",dy_server);
            return HttpClientUtil.post_form(reg_url,data);
        }
}
